package Core;

public class Calculation {

	private int answer;
	private String quest;

	public Calculation() {
		boolean d = false;

		Payments pay = new Payments();
		int fu = (int) ((Math.random() * 10) + (Math.random() * 10) * 5);
		int han = (int) (Math.random() * 10) % 5 + 1;

		if (fu < 20)
			fu = 20;

		if ((fu == 20 || fu == 25) && han == 1) {
			if ((int) (Math.random() * 10) % 2 == 0) {
				fu = 25;
			} else {
				fu = 20;
			}
			han++;
		}

		int q2 = 0;
		try {
			q2 = pay.payment(fu, han, false, true).height;
		} catch (Exception e) {
			e.printStackTrace();
		}

		int q1 = 0;
		while (q1 == 0) {
			q1 = (int) (Math.random() * 10)
					* 5000
					+ (int) (Math.random() * 10)
					* 1000
					+ (int) (Math.random() * 10)
					* 100;
		}

		if ((int) (Math.random() * 10) % 2 == 0) {
			d = true;
			answer = q1 + q2;
		} else {
			d = false;
			answer = q1 - q2;
		}

		quest = q1 + (d == true ? " + " : " - ") + q2 + " = ";

	}

	public String getQuest() {
		return quest;
	}

	public int getAnswer() {
		return answer;
	}

	public boolean isCorrect(int check) {
		if (answer == check || answer == check * 100)
			return true;
		return false;
	}

}
